package main
import (
	"fmt"
)
//类型断言的最佳实践2！
//循环判断传入参数的类型~！ **********
type Student struct{

}
func main(){
	n1 := 1.1
	n2 := 2
	n3 := false
	var n4 float64 = 9.9
	stu1 := Student{}
	stu2 := &Student{}
	TypeJudge(n1,n2,n3,n4,stu1,stu2)
}

func TypeJudge (items ...interface{}){  //判断输入参数是什么类型
	for i,x := range items{
		switch x.(type){  //type 是 关键字，固定写法
		case bool:
			fmt.Printf("param is #%d is a bool value is %v \n",i,x)
		case float64:
			fmt.Printf("param is #%d is a float64 value is %v \n",i,x)
		case int,int64:
			fmt.Printf("param is #%d is a int value is %v \n",i,x)
		case nil:
			fmt.Printf("param is #%d is a nil value is %v \n",i,x)
		case Student:
			fmt.Printf("param is #%d is a Student value is %v \n",i,x)
		case *Student:
			fmt.Printf("param is #%d is a *Student value is %v \n",i,x)
		default:
			fmt.Printf("param is #%d is unknown type; value is %v \n",i,x)
		}
	}
}

